﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Entity;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CallCenter.Model;

namespace CallCenter.Gui
{
    public partial class CustomerListForm : Form
    {
        private List<Customer> customers;
        public CustomerListForm()
        {
            InitializeComponent();
        }


        private void CustomerListForm_Load(object sender, EventArgs e)
        {
            using (var context = new WGRUSEntities())
            {
                customers = context.Customers.ToList();
            }
            customerBindingSource.DataSource = customers;
        }

        private void bt_CreateOrder_Click(object sender, EventArgs e)
        {
            Customer cust = customerBindingSource.Current as Customer;
            if (cust == null)
            {
                MessageBox.Show("Der skal være valgt en kunde", "Fejl", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Form f = new OrderCardForm(cust.TelefonNr);
            f.MdiParent = this.MdiParent;
            f.Show();
        }
    }
}
